(function() {
  function checknumber (num) {
      return true;
  }
  $(document).on("touchstart", ".ok", function() {
      var num = $(".input").val()
      if(!/^(13[0-9]|14[0-9]|15[0-9]|18[0-9])\d{8}$/i.test(num)) {
          alert("号码格式错误，请检查^_^");
          return;
      }else if($(".inputname").val().length == 0) {
          alert("姓名或微信号不能空，请检查^_^");
          return;
      }
      var name = $(".inputname").val()
      if(result = checknumber(num)) {
//          var _url = "/pangleme/submit-phone" + "/" + num + "/" + name;
          var _url = "/pangleme/submit-phone" + "/" + num;
            $.ajax({
                url: _url,
                dataType: 'html',
                type: 'GET',
                data: {
                    name: name
                },
                beforeSend: function(){
                },
                error: function(xhr, type, exception){
                },
                success: function(data){
                    if(data == 'ok'){
//                        window.location.href = "/pangleme/success";
                        $("#input").remove();
                        $("#inputname").remove();
                        $(".ok").remove();
                        $(".comment").remove();
                        $(".congratulations").css({"opacity": 1});
                        $(".link").css({"opacity": 1});
//                        $(".ingroup").addClass("fadeInLeft");
//                        $(".qrcode").addClass("fadeInLeft");
                    }else {
                        alert("报名重复，无需再次报名^_^感谢您的支持!");
                    }
                }
            });
      } else {
        ;
      }
  });
    $(document).on("touchstart", "div.link", function(e) {
        window.location.href = $(this).find("a").attr("href");
    });
})();
